<script>

import * as echarts from 'echarts';
export default {
  name: 'VisualizationTwelve',
  data() {
    return{

    }
  },
  mounted() {
    this.getData();
  },
  methods:{open1(msg) {
      this.$notify({
        title: msg,
        message: '这是一条成功的提示消息',
        type: 'success'
      });
    },
    open2(msg) {
      this.$notify({
        title: msg,
        message: '这是一条警告的提示消息',
        type: 'warning'
      });
    },
    open4(msg) {
      this.$notify.error({
        title: msg,
        message: '这是一条错误的提示消息'
      });
    },
    getData(){
      this.$axios.get('/api/vis/getData14', {

      }).then(res =>{
        let data1 = [];
        let data2 = [];
        if (res.data.code === 20041) {
          for (let i = 0; i < res.data.data.length; i++) {
            data1.push(res.data.data[i]["param"])
            data2.push(res.data.data[i]["param1"])
          }
        }
        this.init(data1, data2);

      }).catch(error =>{
        error = "系统出错了"
        this.open4(error)
      });


    },

    init(data1, data2) {

      var chartDom = document.getElementById('main-box12');
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        color: ['#e99712'],
        title: {
          text: '燃气汇总',
        },
        tooltip: {
          trigger: 'axis',
          axisPointer: {
            type: 'shadow'
          },
          formatter: '{b} : {c}'
        },
        xAxis: {
          type: 'category',
          data: data1
        },
        yAxis: {
          type: 'value'
        },
        series: [
          {
            data: data2,
            type: 'bar',
            itemStyle: {
              normal: {
                barBorderRadius:[100, 100, 10, 10]
              }
            }
          }
        ]
      };

      option && myChart.setOption(option);


    }
  }
}

</script>

<template>
  <div id="main-box12"></div>
</template>

<style scoped>
#main-box12 {
  height: 100%;
  width: 100%;
}
</style>